import request from "@/utils/request";
import { praseStrEmpty } from "@/utils/ruoyi";

// 查询用户列表
export function listUser(query) {
  return request({
    url: "/system/user/page",
    method: "get",
    params: query,
  });
}

// 获取用户精简信息列表
export function listSimpleUsers() {
  return request({
    url: "/system/user/list-all-simple",
    method: "get",
  });
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: "/system/user/get?id=" + praseStrEmpty(userId),
    method: "get",
  });
}

// 新增用户
export function addUser(data) {
  return request({
    url: "/system/user/create",
    method: "post",
    data: data,
  });
}

// 修改用户
export function updateUser(data) {
  return request({
    url: "/system/user/update",
    method: "put",
    data: data,
  });
}

// 删除用户
export function delUser(userId) {
  return request({
    url: "/system/user/delete?id=" + userId,
    method: "delete",
  });
}

// 导出用户
export function exportUser(query) {
  return request({
    url: "/system/user/export",
    method: "get",
    params: query,
    responseType: "blob",
  });
}

// 用户密码重置
export function resetUserPwd(id, password) {
  const data = {
    id,
    password,
  };
  return request({
    url: "/system/user/update-password",
    method: "put",
    data: data,
  });
}

// 部门状态修改
export function changeUserStatus(id, status) {
  const data = {
    id,
    status,
  };
  return request({
    url: "/system/dept/update-status",
    method: "put",
    data: data,
  });
}

// 用户状态修改
export function changeUserInfoStatus(id, status) {
  const data = {
    id,
    status,
  };
  return request({
    url: "/system/user/update-status",
    method: "put",
    data: data,
  });
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: "/system/user/profile/get",
    method: "get",
  });
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: "/system/user/profile/update",
    method: "put",
    data: data,
  });
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword,
  };
  return request({
    url: "/system/user/profile/update-password",
    method: "put",
    data: data,
  });
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: "/system/user/profile/update-avatar",
    method: "put",
    data: data,
  });
}

// 下载用户导入模板
export function importTemplate() {
  return request({
    url: "/system/user/get-import-template",
    method: "get",
    responseType: "blob",
  });
}

// 迁移用户

export function moveUser(data) {
  return request({
    url: "/system/user/move",
    method: "post",
    data: data,
  });
}

// 查询管理门店
export function getUserHaveStore(query) {
  return request({
    url: "/system/dept/store",
    method: "get",
    params: query,
  });
}

// 连续未上钟提醒查询
export function RemindTeacherClock(query) {
  return request({
    url: "/order/teacher-clock/remind",
    method: "get",
    params: query,
  });
}
